package com.sxt.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.support.PagedListHolder;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sxt.sys.domain.Dept;
import com.sxt.sys.mapper.DeptMapper;
import com.sxt.sys.service.DeptService;
import com.sxt.sys.utils.DataGridView;
import com.sxt.sys.vo.DeptVo;
@Service
public class DeptServiceImpl implements DeptService{
	@Autowired
	private DeptMapper deptMapper;
	
	
	@Override
	public DataGridView queryAllDept(DeptVo DeptVo) {
		Page<Object> page = PageHelper.startPage(DeptVo.getPage(),DeptVo.getLimit());
		List<Dept> data = deptMapper.queryAllDept(DeptVo);
		return new DataGridView(page.getTotal(),data);
	}


	@Override
	public Integer addDept(DeptVo deptVo) {
		// TODO Auto-generated method stub
		deptVo.setOrdernum(deptVo.getOrdernum()+1);
		
		return deptMapper.insertSelective(deptVo);
	}


	@Override
	public Integer deleteDept(Integer id) {
		// TODO Auto-generated method stub
		return deptMapper.deleteByPrimaryKey(id);
	}


	@Override
	public List<Dept> queryAllDeptForlist(DeptVo deptVo) {
		// TODO Auto-generated method stub
		return deptMapper.queryAllDept(deptVo);
	}


	@Override
	public Integer queryMaxOrderNumber() {
		// TODO Auto-generated method stub
		return deptMapper.queryMaxOrderNumber();
	}


	@Override
	public Integer updateDept(DeptVo deptVo) {
		// TODO Auto-generated method stub
		return deptMapper.updateByPrimaryKeySelective(deptVo);
	}


	@Override
	public Integer isThisDeptObjHasChildren(Integer id) {
		// TODO Auto-generated method stub
		return deptMapper.queryByIdChildrend(id);
	}



}
